#ifndef							__ASOCKET_H__
#define							__ASOCKET_H__

#include						<qobject.h>
#include						"handler.h"
#include						"byte.h"
#include						"RotatingBuffer.h"

class							ASocket : public QObject
{
	Q_OBJECT

public:
	enum eSocketType
	{
		UDP,
		TCP
	};

protected:
	unsigned int				_id;
	PacketHandler				*_handler;
	byte						_tmp_buf[4096];
	unsigned short				_current_msg;
	RotatingBuffer				_buffer;
	eSocketType					_type;

public:
	ASocket(unsigned int id) : _current_msg(0), _id(id), _handler(NULL), _buffer(4096) {};
	virtual ~ASocket() {};

public:
	virtual void				setHandler(PacketHandler *handler);
	virtual eSocketType			getSocketType() const;
	virtual void				init() = 0;
	virtual void				close() = 0;
	virtual void				sendPacket(Packet *) = 0;
	virtual unsigned int		getId() const;
	virtual QHostAddress 		getIp() const = 0;

protected:
	virtual void				_getOrderSize();
};

#endif							//!__ASOCKET_H__